package chapter02

import scala.collection.mutable
import scala.util.Random

object Test34_PlayCards {
  def main(args: Array[String]): Unit = {
    //花色
    val huase = List("♠", "♥", "♣", "♦")
    val number =
      List("A", "2", "3", "4", "5", "6", "7", "8", "9", "10", "J", "Q", "K")
    val list = number.flatMap(e => {
      huase.map(f => {
        f + e
      })
    })
    println(list)
    val list2 = for (i <- number; j <- huase) yield j + i
    println(list2)
    //加入大王和小王
    val list1 = list :+ "大王" :+ "小王"
    println(list1)
    //洗牌
    val list3 = Random.shuffle(list1)
    println(list3)
    val play1 = list3.take(17)
    val play2 = list3.slice(17, 34)
    val dipai = list3.takeRight(3)
    val play3 = list3.dropRight(3).takeRight(17)
    println(play1)
    println(play2)
    println(play3)
    println(dipai)
    //排序
    println(play1.sortWith((x,y)=>{x.substring(1)<y.substring(1)}))
    println(play2.sortWith((x,y)=>{x.substring(1)<y.substring(1)}))
    println(play3.sortWith((x,y)=>{x.substring(1)<y.substring(1)}))
  }
}
